/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.appspot.trick.it.admin.task;

import com.appspot.trick.it.admin.api.DriveAPIService;
import com.appspot.trick.it.admin.controller.MainController;
import com.appspot.trick.it.admin.model.ArticleModel;
import com.google.api.services.drive.model.File;
import javafx.concurrent.Service;
import javafx.concurrent.Task;

/**
 *
 * @author imamura
 */
public class ImagesUpdateTask extends Service<File> {
    
    private ArticleModel articleModel;
    private java.io.File file;


    /**
     * コンストラクタ
     *
     * @param articleModel
     * @param file
     */
    public void run(ArticleModel articleModel, java.io.File file) {
        this.articleModel = articleModel;
        this.file = file;
        this.restart();
    }

    @Override
    protected Task<File> createTask() {
        return new Task<File>() {

            @Override
            protected File call() throws Exception {
                
                DriveAPIService driveService = new DriveAPIService();
                return driveService.getFileInsert(articleModel.getDriveDriKey(), file).execute();

            }
        };

    }

}
